#include "debugMode.h"
#include "yellowSpiderModel.h"
#include "bulletModel.h"

CDebugMode::CDebugMode( CInput *input,CEngine *engine,CDraw *draw,CSound *sound,CGame *game )
		:CMode( input,engine,draw,sound,game )
{
	obj=new CObject();
	obj->local.Set( 0.0f,0.0f,0.0f );
	obj->rx=D3DX_PI*0.0f;
	obj->ry=D3DX_PI*0.0f;
	obj->rz=D3DX_PI*0.0f;
	//obj->model=CPlayerModel::GetInstance();
	//obj->model=CYellowSpiderModel::GetInstance();
	obj->model=CBulletModel::GetInstance();
}

VOID CDebugMode::Control()
{
	m_input->ReadKeyboard();
	float step=0.1f;
	if( m_input->IsDownKeyDown() )
	{
		obj->local.y-=step;
	}else if( m_input->IsUpKeyDown() )
	{
		obj->local.y+=step;
	}
	
	if( m_input->IsLeftKeyDown() )
	{
		obj->local.x-=step;
	//	obj->ry=0.3f;
	}else if( m_input->IsRightKeyDown() )
	{
		obj->local.x+=step;
	//	obj->ry=-0.3f;
	}else
	{
	//	obj->ry=0.0f;
	}

	m_input->ReadMouse();
	if( m_input->IsLeftButtonDown() )
	{
		if( m_input->IsMouseMoveDown() )
		{
			obj->rx+=step;
			if( obj->rx>D3DX_PI*2 )
			{
				obj->rx=0;
			}
		}
		if( m_input->IsMouseMoveUp() )
		{
			obj->rx-=step;
			if( obj->rx<0.0f )
			{
				obj->rx=D3DX_PI*2;
			}
		}


		if( m_input->IsMouseMoveLeft() )
		{
			obj->ry+=step;
			if( obj->ry>D3DX_PI*2 )
			{
				obj->ry=0;
			}
		}
		if( m_input->IsMouseMoveRight() )
		{
			obj->ry-=step;
			if( obj->ry<0.0f )
			{
				obj->ry=D3DX_PI*2;
			}

		}

	}
	if( m_input->IsWheelDown() )
	{
		obj->local.z-=3*step;
	}
	if( m_input->IsWheelUp() )
	{
		obj->local.z+=3*step;
	}
	
}


VOID CDebugMode::Draw( DWORD dwNow,DWORD dwFPS )
{

	m_draw->BeginDraw();

	m_draw->Draw( obj );

	m_draw->EndDraw();

}

CDebugMode::~CDebugMode()
{
	delete obj;
	obj=NULL;
}